cmake_minimum_required(VERSION 3.5)
project(JTT080-2019-client CXX)

set(GNU 0)
set(CLANG 0)
set(MSVC 0)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    set(CLANG 1)
	message("Clang")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    set(GNU 1)
	message("GNU")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
    set(MSVC 1)
	message("MSVC")
endif()


include(CheckIncludeFileCXX)

check_include_file_cxx(any HAS_ANY)
check_include_file_cxx(string_view HAS_STRING_VIEW)
check_include_file_cxx(coroutine HAS_COROUTINE)
if (NOT "${CMAKE_CXX_STANDARD}" STREQUAL "")
    # Do nothing
elseif (HAS_ANY AND HAS_STRING_VIEW AND HAS_COROUTINE)
    set(CMAKE_CXX_STANDARD 20)
elseif (HAS_ANY AND HAS_STRING_VIEW)
    set(CMAKE_CXX_STANDARD 17)
else ()
    set(CMAKE_CXX_STANDARD 14)
endif ()

message(STATUS "C++标准: c++${CMAKE_CXX_STANDARD}")

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_executable(${PROJECT_NAME} main.cpp)
if (GNU)
	target_link_libraries(${PROJECT_NAME} pthread)
endif()

aux_source_directory(Util Util_SRC)
aux_source_directory(Request Request_SRC)
aux_source_directory(Session Session_SRC)
aux_source_directory(Task Task_SRC)

target_sources(${PROJECT_NAME}
               PRIVATE
               ${Util_SRC}
               ${Request_SRC} 
               ${Session_SRC} 
               ${Task_SRC} ) 
